package com.cino.basic.listener;
import com.cino.system.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener//表明该类是一个监听器
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    PermissionService permissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //扫描我们的自定义注解:获取name和sn
        //扫描每个接口类:1.类上的@RequestMapping 2.每个方法上XxxMapping
        System.out.println("上下文对象创建成功");
        new Thread(new Runnable() {
            @Override
            public void run() {
                permissionService.scanPermission();
            }
        }).start();
    }

}
